package com.Questions.doublePointer;

public class leetcode58 {
    public int lengthOfLastWord(String s) {
        int i=s.length()-1;
        for(;i>=0;--i){
            if(Character.isLetterOrDigit(s.charAt(i))){
                break;
            }
        }
        int res=0;
        for(int j=i;j>=0;--j){
            if(!Character.isLetterOrDigit(s.charAt(j))){
                break;
            }
            res++;
        }
        return res;
    }
}
